﻿using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Sys;
using Rhonin.Common.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.Mongo.Sys.Impl
{
    [Component(LifeStyle.Singleton)]
    public class SysColumnQueryService : ISysColumnQueryService
    {
        private readonly ISysRepository<SysColumn> _sysColumnRepository;
        public SysColumnQueryService(ISysRepository<SysColumn> sysColumnRepository)
        {
            _sysColumnRepository = sysColumnRepository;
        }

        public SysColumn Get(Expression<Func<SysColumn, bool>> where)
        {
            return _sysColumnRepository.GetQuery().FirstOrDefault(where);
        }

        public List<SysColumn> GetList(Expression<Func<SysColumn, bool>> where)
        {
            return _sysColumnRepository.GetQuery().Where(where).ToList();
        }
    }
}
